﻿@model Tau.ViewModels.ProductList


<table border="1">
    <tr>
        <th></th>
        <th></th>
        <th bgcolor="#cccccc">
            <a href="#" onclick="sortList('ProductName');">Name</a>
            @if (Model.SortBy == "ProductName")
            {
                if (Model.SortDescending)
                {
                    @("v")
                }
                else
                {
                    @("^")
                }
            }
        </th>
        <th>
            <a href="#" onclick="sortList('ProductNumber');">Product Number</a>
            @if (Model.SortBy == "ProductNumber")
            {
                if (Model.SortDescending)
                {
                    @("v")
                }
                else
                {
                    @("^")
                }
            }
        </th>
        <th>
            <a href="#" onclick="sortList('Price');">Price</a>
            @if (Model.SortBy == "Price")
            {
                if (Model.SortDescending)
                {
                    @("v")
                }
                else
                {
                    @("^")
                }
            }
        </th>
        <th>
            <a href="#" onclick="sortList('ShippingCost');">ShippingCost</a>
            @if (Model.SortBy == "ShippingCost")
            {
                if (Model.SortDescending)
                {
                    @("v")
                }
                else
                {
                    @("^")
                }
            }
        </th>
        <th>
            <a href="#" onclick="sortList('Spotlight');">Spotlight</a>
            @if (Model.SortBy == "Spotlight")
            {
                if (Model.SortDescending)
                {
                    @("v")
                }
                else
                {
                    @("^")
                }
            }
        </th>
    </tr>

    @foreach (var product in Model.Products) {
        <tr>
            <td>
                @if (product.ImageId != null && product.ImageId > 0)
                {
                    <img width="100px" id="selImageThumbnailUrl" src="@Url.Action("GetImage", "Image", new { id = product.ImageId, type = "thumbnail", area = "" })"  />
                }
            </td>
            <td>
                <a href="javascript:;" onclick="popupAddEdit(@product.ProductId);" style="cursor:pointer">Edit</a> |
                <a href="javascript:;" onclick="deleteProduct(@product.ProductId, '@product.ProductNumber');" style="cursor:pointer">Delete</a>
            </td>
            <td>
                @product.ProductName
            </td>
            <td>
                @product.ProductNumber
            </td>
            <td>
                @string.Format("{0:C}", product.Price)
            </td>
            <td>
                @string.Format("{0:C}", product.ShippingCost)
            </td>
            <td align="center">
                @if (product.Spotlight)
                {
                    <text>x</text>
                }
            </td>
        </tr>
    }
</table>